#pragma once

#include <sstream>
#include "BaseDator.h"

template<class T>
class Dator : public BaseDator
{
public:
	Dator(T& t) : target(t) {}
	BaseDator& operator =(string& input) { target=toVal(input); return *this; }
	BaseDator& operator +=(string& input) { target+=toVal(input); return *this; }
	BaseDator& operator -=(string& input) { target-=toVal(input); return *this; }
	bool operator ==(string& s) { return (s==(string)(*this)); }
	bool operator !=(string& s) { return (s!=(string)(*this)); }
	operator string() { return toString(target); }

	bool hasMultipleValues() { return false; }

	AUTO_SIZE;
protected:
	T& target;
	T toVal(string& s)
	{
		stringstream str;
		str.unsetf(ios::skipws);
		str<<s;
		T res;
		str>>res;
		return res;
	}
  
	string toString(T& val)
	{
		stringstream str;
		str.unsetf(ios::skipws);
		str<<val;
		string res;
		str>>res;
		return res;
	}
};
